package com.pxy.test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.Date;

/**
 * Created by Administrator on 2017/9/11.
 */

public class DataCompare implements Comparator<B> {
    SimpleDateFormat sdf =   new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    @Override
    public int compare(B o1, B o2) {
        try {
            Date parse1 = sdf.parse(o1.getDate());
            Date parse2 = sdf.parse(o2.getDate());
            return -parse1.compareTo(parse2);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return 0;
    }
}
